<template>
	<view class="content">
		<view class="block tickets-block">
			<view class="block date-block">
				<view v-for="(item,index) in date" :key="item.id" @click="dateActive=index"
					:class="dateActive==index?'active':''" class="date-item">
					<view class="date">{{item.date}}</view>
					<view class="name">{{item.name}}</view>
				</view>
			</view>
			<navigator hover-class="none" :url="'/pages/attractions/detail?id='+item.id" v-for="(item,index) in tickets"
				:key="item.id" class="tickets-item">
				<image mode="aspectFill" :src="item.picUrl" class="photo"></image>
				<view class="info-block">
					<view class="name">{{item.ticketName}}</view>
					<view class="label-block">
						<view v-for="(item1,index1) in item.label" class="label-item">{{item1}}</view>
					</view>
					<view class="describe">{{item.ticketDsc}}</view>
					<view class="price">￥{{item.ticketFare}}</view>
					<view class="btn1 btn">立即预订</view>
				</view>
			</navigator>
		</view>
	</view>
</template>

<script>
	import {
		getViewById
	} from '@/api/attractions.js';
	export default {
		data() {
			return {
				id: null,
				date: [],
				dateActive: 0,
				tickets: []
			}
		},
		mounted() {
			let _this = this;
			let date = [];
			for (let i = 0; i < 4; i++) {
				let res = _this.utils.getCurrentTime('d', '/', i);
				res = res.slice(5);
				let text = ''
				switch (i) {
					case 0:
						text = '今天';
						break;
					case 1:
						text = '明天';
						break;
					case 2:
						text = '后天';
						break;
					case 3:
						text = '';
						break;
				}
				date.push({
					date: res,
					name: text,
				})
			}
			this.date = date;
		},
		onLoad(e) {
			console.log(e)
			this.id = e.id
			this.getTicketList()
		},
		methods: {
			getTicketList() {
				let id = this.id
				getViewById({
					id
				}).then((res) => {
					if (res.code == 1) {
						if (res.data != null) {
							console.log(res)
							this.tickets = res.data.ticketList
						}
					} else {
						console.log(res)
					}
				}).catch((res) => {
					console.log(res)
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		background-color: #F4F4F4;
		height: 100%;
		width: 100%;

		.block.date-block {
			margin-top: 10rpx;
			padding-bottom: 0;
			display: flex;
			flex-direction: row;
			border-radius: 40rpx;
			box-shadow: 0 0 10px 0px rgba(0, 0, 0, 0.08);
			position: relative;

			.date-item {
				flex-grow: 1;
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: center;
				background: #fff;
				padding: 30rpx 0;

				.date {
					font-weight: bold;
					font-size: 28rpx;
					margin-right: 10rpx;
				}

				.date.more {
					font-weight: normal;
				}

				.name {
					font-size: 28rpx;
					color: $color-secondary-text;
				}
			}

			.date-item:first-child {
				border-radius: 50rpx 0 0 50rpx;
			}

			.date-item:last-child {
				border-radius: 0 50rpx 50rpx 0;
			}

			.date-item.active {
				background: $color-primary;
				color: #fff;

				.name {
					color: #fff;
				}
			}
		}

		.block.tickets-block {
			display: flex;
			flex-direction: column;
			padding: 30rpx;

			.tickets-item {
				width: 100%;
				background: #fff;
				border-bottom: 1px solid #efefef;
				padding: 30rpx;
				padding-top: 70rpx;
				display: flex;
				flex-direction: row;

				.photo {
					width: 250rpx;
					height: 250rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;
				}

				.info-block {
					width: calc(100% - 270rpx);
					display: flex;
					flex-direction: column;
					position: relative;

					.name {
						font-size: 34rpx;
					}

					.label-block {
						width: 100%;
						display: flex;
						flex-direction: row;
						flex-wrap: wrap;
						margin: 10rpx 0;

						.label-item {
							font-size: 24rpx;
							color: $color-primary;
							background: rgba(64, 158, 255, .1);
							padding: 4rpx 6rpx;
							margin-right: 10rpx;
							border-radius: 6rpx;
							margin-bottom: 10rpx;
						}
					}

					.describe {
						font-size: 28rpx;
						color: $color-secondary-text;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2;
						overflow: hidden;
					}

					.price {
						margin-top: 16rpx;
						color: $color-danger;
						font-weight: bold;
					}

					.btn {
						position: absolute;
						width: 160rpx;
						height: 60rpx;
						font-size: 26rpx;
						bottom: -10rpx;
						right: -10rpx;
					}
				}

			}
		}
	}
</style>
